﻿using Cms.Application.WebFramework.Views;
using Cms.Data;
using Cms.Domain;
using Cms.Domain.RepositoryInterfaces;

namespace Cms.Application.WebFramework.Presenters
{
    public class CustomAdminPagePresenter : BasePresenter
    {
        private readonly CustomAdminPage _customAdminPage;
        private readonly ICustomAdminPageView _view;

        public CustomAdminPagePresenter(ICustomAdminPageView view)
            : this(view, new RepositoryFactory())
        {
        }

        public CustomAdminPagePresenter(ICustomAdminPageView view, IRepositoryFactory repositoryFactory)
            : base(view, repositoryFactory)
        {
            _view = view;
            _customAdminPage = SystemRepository.GetCustomAdminPageByFilename(_view.Filename);
        }

        public void SetHeading()
        {
            _view.SetHeading(_customAdminPage.Name);
        }
    }
}
